//
//  ZPMainViewController.swift
//  ZPWeiBo01
//
//  Created by Nevermore on 16/9/1.
//  Copyright © 2016年 Nevermore. All rights reserved.
//

import UIKit

class ZPMainViewController: UITabBarController {

    override func viewDidLoad() {
        super.viewDidLoad()
        let tabBar = ZPTabBar()
        //设置代理
        tabBar.zpdelegate = self
        
        setValue(tabBar, forKey: "tabBar")
        
         addChildViewController(ZPHomeViewController(), imgName:
        "tabbar_home", title: "首页")
         addChildViewController(ZPMessageViewController(), imgName: "tabbar_message_center", title: "消息")
         addChildViewController(ZPDiscoverViewController(), imgName: "tabbar_discover", title: "发现")
         addChildViewController(ZPProfileViewController(), imgName: "tabbar_profile", title: "我")
        
           }

    func addChildViewController(vc:UIViewController,imgName:String,title:String){
//        vc.navigationItem.title = title
//        vc.tabBarItem.title = title
        vc.title = title
        vc.tabBarItem.setTitleTextAttributes([NSForegroundColorAttributeName:UIColor.orangeColor()], forState: UIControlState.Selected)
        vc.tabBarItem.image = UIImage(named: imgName)
        vc.tabBarItem.selectedImage = UIImage(named: "\(imgName)_selected")?.imageWithRenderingMode(UIImageRenderingMode.AlwaysOriginal)
        addChildViewController(UINavigationController(rootViewController: vc))
        
        
        
    }
    
    
    
}
extension ZPMainViewController:ZPTabBarDelegate{
    
    func tabBarButtonClick() {
        print("撰写按钮点击了")
    }
    
    
    
}